<!DOCTYPE html>
<html ng-app="myApp">
	<head>
		<meta charset="UTF-8">
		<title>day05</title>
		<script src="../AngularJS-1.4.1/js/angular.js"></script>
		<script src="../AngularJS-1.4.1/js/angular-route.js"></script>
	</head>
	<body ng-controller="indexCtrl">
		<h1>我是首页</h1>
		<a href="#/tpl/regist">我是注册页面</a>
		<a href="#/tpl/detail">我是详情页面</a>
		
		<!--加载页面容器-->
		<div ng-view></div>
	</body>
	
	<script>
		//申明一个模块
		var app = angular.module('myApp',['ng','ngRoute']);
		
		//配置路由词典
		app.config(function($routeProvider){
			$routeProvider
				.when('/tpl/regist',{
					templateUrl:'tpl/regist.html',
					controller:'registCtrl'					
				})
				.when('/tpl/regist/:id',{
					templateUrl:'tpl/regist.html',
					controller:'sendCtrl'
					
				})
				
				.when('/tpl/detail',{
					templateUrl:'tpl/detail.html',
					controller:'detailCtrl'					
				})
				.when('/tpl/detail/:id',{
					templateUrl:'tpl/detail.html',
					controller:'sendCtrl'
					
				})
				
				.otherwise({
					redirectTo:'index.html'
				})			
		})
		
		//首页控制器
		app.controller('indexCtrl',['$scope','$location',function($scope,$location){
			$scope.jump = function(url){
				$location.path(url);				
			}			
		}])
		
		//注册页面控制器
		app.controller('registCtrl',['$scope','$location',function($scope,$location){
			$scope.num=121
		}])
		
		//详情页面
		app.controller('detailCtrl',['$scope','$location',function($scope,$location){
			$scope.code=222
		}])
		
//		接收方控制器
		app.controller('sendCtrl',['$scope','$routeParams',function($scope,$routeParams){
			console.log($routeParams.id);
			
		}])
		
		
	</script>
	
</html>
